package com.chris.datacnter;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.UUID;

//springboot 启动类  禁用以下自动配置
@SpringBootApplication()//exclude= {DataSourceAutoConfiguration.class}
public class DataCnterBoot {

    public static void main(String[] args) {
        System.setProperty("localIP", getUniqName());

        SpringApplication.run(DataCnterBoot.class, args);
    }

    private static String getUniqName() {
        String localIp = null;
        try {
            localIp = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            //LOG.error("fail to get ip...", e);
        }
        String uniqName = UUID.randomUUID().toString().replace("-", "");
        if (localIp != null) {
            uniqName = localIp + "-" + uniqName;
        }
        return uniqName;
    }
}
